const app = getApp();
Page({
  data: {
    content: '',
    id: '',
    disabledSubmit: true,
  },
  onLoad(option) {
    this.setData({
      id: option.id
    })
  },
  bindContentInput(e) {
    var bl = true;
    if (e.detail.value != '') {
      bl = false;
    }
    this.setData({
      content: e.detail.value,
      disabledSubmit: bl
    })
  },
  onSubmit() {
    var that = this;
    dd.showLoading({
      content: '提交中...',
      delay: 1000,
    });
    dd.httpRequest({
      url: 'http://www.ejzcat.com/dingapi/equipmentrepair/evaluatememo.ashx',
      method: 'POST',
      data: {
        type: 'insert',
        repairId: that.data.id,
        userId: app.globalData.userid,
        userName: app.globalData.username,
        department: app.globalData.department,
        content: that.data.content,
      },
      dataType: 'json',
      success: function(res) {
        if (res.data == 1) {
          dd.navigateBack({
            delta: 1
          });
        }
        else {
          dd.alert({ content: '提交失败' });
        }
      },
      fail: function(err) {
        dd.alert({ content: JSON.stringify(err) });
      },
      complete: function() {
        dd.hideLoading();
      }
    })
  },
});
